/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.lostreseditores.modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author DILOVE
 */
@Entity
@Table(name = "presentaexamen")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Presentaexamen.findAll", query = "SELECT p FROM Presentaexamen p"),
    @NamedQuery(name = "Presentaexamen.findByIdEstudiante", query = "SELECT p FROM Presentaexamen p WHERE p.presentaexamenPK.idEstudiante = :idEstudiante"),
    @NamedQuery(name = "Presentaexamen.findByIdExamen", query = "SELECT p FROM Presentaexamen p WHERE p.presentaexamenPK.idExamen = :idExamen"),
    @NamedQuery(name = "Presentaexamen.findByFechaexamen", query = "SELECT p FROM Presentaexamen p WHERE p.fechaexamen = :fechaexamen"),
    @NamedQuery(name = "Presentaexamen.findByEstadoexamen", query = "SELECT p FROM Presentaexamen p WHERE p.estadoexamen = :estadoexamen")})
public class Presentaexamen implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PresentaexamenPK presentaexamenPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fechaexamen")
    @Temporal(TemporalType.DATE)
    private Date fechaexamen;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "estadoexamen")
    private String estadoexamen;
    @JoinColumn(name = "id_examen", referencedColumnName = "id_examen", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Examen examen;
    @JoinColumn(name = "id_estudiante", referencedColumnName = "id_estudiante", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Estudiante estudiante;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "presentaexamen")
    private List<Respuestasexamen> respuestasexamenList;

    public Presentaexamen() {
    }

    public Presentaexamen(PresentaexamenPK presentaexamenPK) {
        this.presentaexamenPK = presentaexamenPK;
    }

    public Presentaexamen(PresentaexamenPK presentaexamenPK, Date fechaexamen, String estadoexamen) {
        this.presentaexamenPK = presentaexamenPK;
        this.fechaexamen = fechaexamen;
        this.estadoexamen = estadoexamen;
    }

    public Presentaexamen(int idEstudiante, int idExamen) {
        this.presentaexamenPK = new PresentaexamenPK(idEstudiante, idExamen);
    }

    public PresentaexamenPK getPresentaexamenPK() {
        return presentaexamenPK;
    }

    public void setPresentaexamenPK(PresentaexamenPK presentaexamenPK) {
        this.presentaexamenPK = presentaexamenPK;
    }

    public Date getFechaexamen() {
        return fechaexamen;
    }

    public void setFechaexamen(Date fechaexamen) {
        this.fechaexamen = fechaexamen;
    }

    public String getEstadoexamen() {
        return estadoexamen;
    }

    public void setEstadoexamen(String estadoexamen) {
        this.estadoexamen = estadoexamen;
    }

    public Examen getExamen() {
        return examen;
    }

    public void setExamen(Examen examen) {
        this.examen = examen;
    }

    public Estudiante getEstudiante() {
        return estudiante;
    }

    public void setEstudiante(Estudiante estudiante) {
        this.estudiante = estudiante;
    }

    @XmlTransient
    public List<Respuestasexamen> getRespuestasexamenList() {
        return respuestasexamenList;
    }

    public void setRespuestasexamenList(List<Respuestasexamen> respuestasexamenList) {
        this.respuestasexamenList = respuestasexamenList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (presentaexamenPK != null ? presentaexamenPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Presentaexamen)) {
            return false;
        }
        Presentaexamen other = (Presentaexamen) object;
        if ((this.presentaexamenPK == null && other.presentaexamenPK != null) || (this.presentaexamenPK != null && !this.presentaexamenPK.equals(other.presentaexamenPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.lostreseditores.modelo.Presentaexamen[ presentaexamenPK=" + presentaexamenPK + " ]";
    }
    
}
